package com.tedu.bill;

import java.util.Scanner;

/*
* 测试售卖机
* */
public class TestSaleProductMechine {
    public static void main(String[] args) {
        System.out.println("*****欢迎光临毕龙的商品*****");
        System.out.println("1.哇哈哈 2.红牛 3.涨知识 酸奶 4.老坛酸菜泡面 5.零度 6.冰糖雪梨");
        //创建一个Scanner对象
        Scanner scanner = new Scanner(System.in);
        //请输入您的选择
        int selected = scanner.nextInt();
        //调用选择商品
        selectProduct(selected);
    }

    //选择商品的功能
    public static void selectProduct(int selected){
        //用一个switch分支结构
        switch ( selected ){
            case 1:
                System.out.println("哇哈哈");
                System.out.println("价格 3 元");
                alipay(3,"哇哈哈");
                break;
            case 2:
                System.out.println("红牛");
                System.out.println("价格 6 元");
                alipay(6,"红牛");
                break;
            case 3:
                System.out.println("涨知识 酸奶");
                System.out.println("价格 4 元");
                alipay(4,"涨知识 酸奶");
                break;
            case 4:
                System.out.println("老坛酸菜泡面");
                System.out.println("价格 5 元");
                alipay(5,"老坛酸菜泡面");
                break;
            case 5:
                System.out.println("零度");
                System.out.println("价格 3 元");
                alipay(3, "零度");
                break;
            case 6:
                System.out.println("冰糖雪梨");
                System.out.println("价格 3 元");
                alipay(3,"冰糖雪梨");
                break;
            default:
                System.out.println("输入有误");
        }
    }
    //支付的功能
    public static void alipay(double money,String productName){
        System.out.println("请输入 " + money + "元");
        double inputMoney = new Scanner(System.in).nextDouble();
        if(inputMoney == money){
            System.out.println("恭喜您获得了"+productName+"商品，请带走您的商品");
        }else{
            System.out.println("您输入的金额不对！！");
        }
    }
}
